package com.zenghus.v1;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MapperProxy<T> implements InvocationHandler{
    private SqlSession sqlsession;

    public MapperProxy(SqlSession sqlsession) {
        this.sqlsession=sqlsession;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(method.getDeclaringClass().getName()+"\n"+Configuration.TestMapperXml.namespace);
        if(method.getDeclaringClass().getName().equals(Configuration.TestMapperXml.namespace)){
            String sql=Configuration.TestMapperXml.methodmap.get(method.getName());
            return sqlsession.selectOne(sql,args);
        }
        return null;
    }
}
